<form class="tableform" method='post' action='index.php?app=b2c&ctl=admin_order&act=do_confirm' id="order-split-form">
    <input type="hidden" name="business_id" value="<{$business_id}>">
	<table cellpadding="0" cellspacing="0"  class="gridlist">
		<col style="width:10%"></col>
		<col style="width:15%"></col>
		<col style="width:10%"></col>
		<col style="width:15%"></col>
		<col style="width:5%"></col>
		<col style="width:5%"></col>
		<col style="width:10%"></col>
		<col style="width:10%"></col>
		<col style="width:10%"></col>
		<col style="width:5%"></col>
		<col style="width:5%"></col>
		<thead>
		<tr>
			<th><{t}>订单号<{/t}></th>
			<th><{t}>下单时间<{/t}></th>
			<th><{t}>货品编号<{/t}></th>
			<th><{t}>品牌<{/t}></th>
			<th><{t}>数量（包装）<{/t}></th>
			<th><{t}>每包装数量<{/t}></th>
			<th><{t}>销售单价<{/t}></th>
			<th><{t}>采购价<{/t}></th>
			<th><{t}>已确认数量<{/t}></th>
			<th><{t}>确认数量<{/t}></th>
			<th></th>
		</tr>
		</thead>
		<tbody>
		<{foreach from=$info item=item}>
		<tr>
			<td><{$item.childOrder_id}></td>
			<td><{$item.createtime|cdate}></td>
			<td><{$item.bn}></td>
			<td><{$item.brand_name}></td>
			<td><{$item.quantity}></td>
			<td><{$item.unit_num}></td>
			<td><{$item.s_price|cur}></td>
			<td><{$item.s_cost|cur}></td>
			<td><{$item.total_confirm_num}></td>
			<td>
				<{if $item.state=='0'}>
				<!--<{t}>未确认<{/t}>-->
				<{input type="text" vtype="required&&number" name="confirm_num[{$item.obj_id}]" class="toShare" value=$item.quantity  q_data=$item.quantity width="10" onblur="check(this)"}>
				<{else $item.state=='1'}>
				<{t}>已确认<{/t}>
				<{/if}>
			</td>
			<td>
			    <{if $item.state=='0'}>
			    <a href="<{link app=b2c ctl=admin_order act=do_bo_edit obj_id=$item.obj_id business_id=$business_id}>" class="single_confirm"><{t}>确认<{/t}></a>
				<{/if}>
			</td>
		</tr>
		<{/foreach}>
		<{if !count($info) > 0}>
		<tr><td colspan=10><{t}>暂无确认库存数据<{/t}></td></tr>
		<{/if}>
		</tbody>
	</table>
	<{if count($info) > 0}>
	<div class="table-action">
		<{button label=$___b2c="确定"|t:'b2c' id="order-split-form-submit" class="order-action" type="submit"}>
	</div>
	<{/if}>
</div>
</form>

<script type="text/javascript">
(function(){
    var _form = $('order-split-form');
    var btn =$('order-split-form-submit');
    _form.store('target',{
    	onRequest:function() {
    	},
        onComplete:function(){

        },
        onSuccess:function(response){
            var hash_res_obj = JSON.decode(response);
            if (hash_res_obj.success != undefined && hash_res_obj.success != ""){
//                window.close();
                window.location.reload();
            }else{}
        }
    });
})();

function check(obj){
	var gc_confirm_num = obj.get('value');
	var quantity = obj.get('q_data');
	if(isNaN(gc_confirm_num)){
		obj.set('value',quantity);
	}
	if(gc_confirm_num<0){
		obj.set('value',quantity);
	}
	if(gc_confirm_num>quantity){
		obj.set('value',quantity);
	}
}

var confirm = $('order-split-form');
confirm.addEvents({
	'click:relay(.single_confirm)':function(e){
		e.preventDefault();
		var self = this;
		var input = this.getParent('td').getPrevious('td').getElement('.toShare');
		var num = input.get('value');
        self.href += '&con_num=' + num;
		new Request({
			url:self.href,
			method:'post',
			onSuccess:function(re){
				try{
                    var _dialogIns = self.getParent('.dialog').retrieve('instance');
                }catch(e){}

                if(_dialogIns)
                {
                    _dialogIns.close();
                }
			}
		}).send();	
	}
});
</script>